/* 
   http://www.dynamicdrive.com/dynamicindex14/bookflip.htm
   Modified by Abu-Farhan and Catur
   http://www.abu-farhan.com
*/
	var showpostthumbnails_gal  = true;
	var random_posts       		= false;
	var numposts_gal			= 100;
	var Book_Image_Sources=new Array();	
function showgalleryposts(json) {
    var numPosts = json.feed.openSearch$totalResults.$t;
    var indexPosts = new Array();
    for (var i = 0; i < numPosts; ++i) {
        indexPosts[i] = i;
    }
	if (random_posts == true){
    indexPosts.sort(function() {return 0.5 - Math.random()});
	}
    if (numposts_gal > numPosts) {
        numposts_gal = numPosts;
    }
    for (i = 0; i < numposts_gal; ++i) {
        var entry_gal = json.feed.entry[indexPosts[i]];
		var posttitle_gal =  entry_gal.title.$t;
        for (var k = 0; k <  entry_gal.link.length; k++) {
            if ( entry_gal.link[k].rel == 'alternate') {
                posturl_gal =  entry_gal.link[k].href;
                break;
            }
        }
		if ("content" in entry_gal) {
            var postcontent_gal = entry_gal.content.$t
        }
        s = postcontent_gal;
        a = s.indexOf("<img");
        b = s.indexOf("src=\"", a);
        c = s.indexOf("\"", b + 5);
        d = s.substr(b + 5, c - b - 5);
        if ((a != -1) && (b != -1) && (c != -1) && (d != "")) {
            var thumburl_gal = d
        } else var thumburl_gal = 'http://i1133.photobucket.com/albums/m596/abu-farhan/Images_no_image.gif';
		
		if (i== 0){
		var thumb_ = 0;
		var thumb_link = 1;
		}
		else{
		var thumb_ = i * 2;
		var thumb_link = thumb_+1;
		}
		Book_Image_Sources[thumb_]=thumburl_gal;
		Book_Image_Sources[thumb_link]=posturl_gal;
    }
}